﻿namespace Dcms.BLL
{
    using Dcms.IDAL;
    using Dcms.Model;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Configuration;

    public class Dcms_AdminBLL
    {
        private IDcms_AdminDAL adminOp = Dcms.DALFactory.DALFactory.CreateDcms_Admin();
        private static readonly string CODER = ConfigurationManager.AppSettings["Coder"];

        public Dcms_AdminModel AddModel(Dcms_AdminModel model)
        {
            return this.adminOp.AddModel(model);
        }

        public Dcms_AdminModel CheckAdminLogin(string UserName, string PassWord)
        {
            return this.adminOp.CheckAdminLogin(UserName, PassWord);
        }

        public void DeleteAdminByRoleID(int RoleID)
        {
            this.adminOp.DeleteAdminByRoleID(RoleID);
        }

        public void DeleteModelByID(int ID)
        {
            this.adminOp.DeleteModelByID(ID);
        }

        public ArrayList GetCoders()
        {
            string[] strArray = CODER.Split(new char[] { ',' });
            ArrayList list = new ArrayList();
            for (int i = 0; i < strArray.Length; i++)
            {
                list.Add(strArray[i].ToString());
            }
            return list;
        }

        public string GetDataCount(string SqlStr)
        {
            return this.adminOp.GetDataCount(SqlStr);
        }

        public IList<Dcms_AdminModel> GetDataListByPage(string SqlStr, int CurPage, int PageSize)
        {
            return this.adminOp.GetDataListByPage(SqlStr, CurPage, PageSize);
        }

        public Dcms_AdminModel GetModelByID(int ID)
        {
            return this.adminOp.GetModelByID(ID);
        }

        public Dcms_AdminModel GetModelByName(string strAdmin_Name)
        {
            return this.adminOp.GetModelByName(strAdmin_Name);
        }

        public Dcms_AdminModel Update(Dcms_AdminModel model)
        {
            return this.adminOp.Update(model);
        }

        public int UpdatePwd(int AdminId, string PassWord)
        {
            return this.adminOp.UpdatePwd(AdminId, PassWord);
        }

        public int UpdateRole(int AdminId, int RoleId)
        {
            return this.adminOp.UpdateRole(AdminId, RoleId);
        }
    }
}

